//
//  BaseCollectionViewCell.m
//  BasicProject
//
//  Created by 马军凯 on 2023/4/13.
//

#import "BaseCollectionViewCell.h"

@implementation BaseCollectionViewCell

+ (instancetype)baseCellWith:(UICollectionView *)collectionView indexPath:(NSIndexPath *)indexPath {
    NSString *nibName = NSStringFromClass(self);
    NSString *path = [[NSBundle mainBundle] pathForResource:nibName ofType:@"nib"];
    if (path.length > 0) {
        UINib *nib = [UINib nibWithNibName:nibName bundle:[NSBundle mainBundle]];
        [collectionView registerNib:nib forCellWithReuseIdentifier:nibName];
    } else {
        Class class = NSClassFromString(nibName);
        [collectionView registerClass:class forCellWithReuseIdentifier:nibName];
    }
    
    BaseCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:nibName forIndexPath:indexPath];
    
    return cell;
}

@end
